home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
clipper
/
rfntlb10.zip
/
RFNTDEMO.PRG
< prev
next >
Wrap
Text File
|
1994-01-02
|
12KB
|
433 lines
*--------------------------------------------------------------------------
* RFntDemo.PRG - Program to demonstrate the use of the functions
* in the Clipper Library RFntLib
*
* Used functions :
*
* R_DefFnt () - Install default ROM font (EGA or VGA)
* R_EGAFnt () - Install one of the INTERNAL (built-in) EGA fonts
* R_EGAName () - Retrieve the name of an INTERNAL (built-in) EGA font
* R_FntFile () - Load an EXTERNAL EGA or VGA font from a disk file
* R_FntName () - Retrieve the name of the current font
* R_FntNr () - Retrieve the number of the current font
* R_IsEGAFl () - Determine if an EGA card is present
* R_IsVGAFl () - Determine if an VGA card is present
* R_MaxFnt () - Determine the number of INTERNAL (built-in) fonts
* R_VGAFnt () - Install one of the INTERNAL (built-in) VGA fonts
* R_VGAName () - Retrieve the name of an INTERNAL (built-in) VGA font
*
* This demo has been written for Clipper version 5.xx
*
* Compile : CLIPPER RFNTDEMO -N
*
* Link : RTLINK file RFNTDEMO lib RFNTLIB - or -
* BLINKER file RFNTDEMO lib RFNTLIB - or -
* EXOSPACE file RFNTDEMO lib RFNTEXO exo pack int10
*
* Syntax : RFNTDEMO
*--------------------------------------------------------------------------
* Date : 02/01/94
*--------------------------------------------------------------------------
* Author : Ing. R.P.B. van Gelder
* Binnenwiertzstraat 27
* 5615 HG EINDHOVEN
* THE NETHERLANDS
*
* E-Mail : Internet: RCROLF@urc.tue.nl
* BitNet : RCROLF@heitue5
*--------------------------------------------------------------------------
* (c) 1994 Rolf van Gelder, All rights reserved
*--------------------------------------------------------------------------
*--------------------------------------------------------------------------
* STANDARD CLIPPER HEADER FILES
*--------------------------------------------------------------------------
#include "Inkey.ch"
#include "Directry.ch"
*--------------------------------------------------------------------------
* INCLUDE THE RFNTLIB HEADER FILE
*--------------------------------------------------------------------------
#include "RFNTLIB.CH"
*--------------------------------------------------------------------------
* CONSTANTS
*--------------------------------------------------------------------------
#define CRLF CHR(13)+CHR(10)
*--------------------------------------------------------------------------
* STATIC VARIABLES
*--------------------------------------------------------------------------
*-- Flag which indicates where the PC has an EGA or VGA card
STATIC lIsVGA
*-- Initialize error text array using the header file (RFntLib.CH)
STATIC aErrMsg := FL_ERRMSG
*--------------------------------------------------------------------------
* STATIC CODEBLOCKS
*--------------------------------------------------------------------------
*-- "Hit any key" message
STATIC bHitKey := { || DevPos (MaxRow()-1,32), DevOut('Hit any key ....'),;
InKey (0) }
*-- Header line (with clear screen)
STATIC bHeader := { || Scroll (), ;
DispMsg ( 0, 'RFntDemo: Demo program for ' + ;
'RFntLib v1.0 (C) 1994 ' + ;
'Rolf van Gelder', 'W+/BG' ) }
*--------------------------------------------------------------------------
*
* M A I N P R O G R A M
*
*--------------------------------------------------------------------------
FUNCTION RFntDemo
*-- Array with menu choices
LOCAL aMenu := { ;
'Load an INTERNAL screen font .... R_VGAFnt(), R_EGAFnt()', ;
'Load an EXTERNAL screen font ............... R_FntFile()', ;
'Install the DEFAULT ROM font ................ R_DefFnt()', ;
'Display the NAME of the current font ..... R_FntName()', ;
'Display the NUMBER of the current font ....... R_FntNr()', ;
'Display the current CHARACTER SET', ;
'Symbols & Icons in the RSymbol1 & RSymbol2 fonts', ;
'End of Demo' }
LOCAL nChoice := 1 && Menu choice made
LOCAL cOldCol && Screen color
LOCAL nIntFont && Number of internal font
LOCAL nFonts && Number of internal fonts
LOCAL nCnt && Counter
LOCAL aIntFnts := {} && Internal font names
LOCAL nRetCode && Return code
*-- Set Color to Bright While on Blue
SetColor ( 'W+/B' )
*-- Determine if an EGA card is present
IF !R_IsEGAFl ()
*-- No EGA nor VGA
Alert ( 'I am sorry ... EGA adapter or better required !' )
RETURN nil
ENDIF
*-- Determine if an VGA card is present and save it to a static var
lIsVGA := R_IsVGAFl ()
*-- Determine the number of INTERNAL (built-in) fonts
nFonts := R_MaxFnt ()
*-- Create an array containing the names of the INTERNAL fonts
FOR nCnt := 1 TO nFonts
IF lIsVGA
*-- Add the name of an INTERNAL VGA font
AAdd ( aIntFnts, R_VGAName ( nCnt ) )
ELSE
*-- Add the name of an INTERNAL EGA font
AAdd ( aIntFnts, R_EGAName ( nCnt ) )
ENDIF
NEXT
*--------------------------------------------------------------------------
* M A I N L O O P
*--------------------------------------------------------------------------
DO WHILE .t.
*-- Display header lines
Eval ( bHeader )
*-- Display footer font name
DispMsg ( 24, '<Current font: ' + Trim ( R_FntName () ) + '>', 'W+/BG' )
DevPos ( 3, 31 )
DevOut ( '-+- MAIN MENU -+-' )
*-- Draw box
Scroll ( 5, 10, 14, 69 )
DispBox ( 5, 10, 14, 69, 1 )
*-- Display main menu and get a choice
nChoice := AChoice ( 6, 12, 13, 67, aMenu, , , nChoice )
IF LastKey () = K_ESC .or. nChoice = Len ( aMenu )
*-- Canceled
EXIT
ENDIF
DO CASE
CASE nChoice = 1
*-- INTERNAL FONT
cOldCol := SetColor ( 'W+/RB' )
DispMsg ( 24, 'CHOOSE THE INTERNAL FONT FILE TO LOAD (Esc=Cancel)' )
*-- Choose a font file
DispBox ( 7, 22, 7 + R_MaxFnt () + 1, 57, 1 )
nIntFont := AChoice ( 8, 23, 8 + R_MaxFnt() - 1, 56, aIntFnts )
SetColor ( cOldCol )
IF LastKey () = K_RETURN
nRetCode := R_VGAFnt ( nIntFont )
IF nRetCode != FL_OKAY
*-- Display error message, using pre-defined array
Alert ( aErrMsg [nRetCode] )
ENDIF
ENDIF
CASE nChoice = 2
*-- LOAD AN EXTERNAL FONT FROM DISK
LoadExtFnt ()
CASE nChoice = 3
*-- INSTALL DEFAULT ROM FONT (EGA OR VGA)
R_DefFnt ()
CASE nChoice = 4
*-- GET CURRENT FONT NAME
Alert ( 'The NAME of the current font = ' + R_FntName () )
CASE nChoice = 5
*-- GET THE NUMBER OF THE CURRENT FONT
Alert ( 'The NUMBER of the current font = ' + ;
LTrim ( Str ( R_FntNr () ) ) )
CASE nChoice = 6
*-- SHOW CHARACTER SET
ShowSet ()
CASE nChoice = 7
*-- SYMBOL/ICON DEMO
SymbolDemo ()
ENDCASE
ENDDO
*-- INSTALL DEFAULT ROM FONT (EGA OR VGA)
R_DefFnt ()
*-- Clear screen
Scroll ()
RETURN nil
*--------------------------------------------------------------------------
*
* LOAD AN EXTERNAL FONT FROM DISK
*
*--------------------------------------------------------------------------
STATIC FUNCTION LoadExtFnt
LOCAL aDirectory := {} && Directory array
LOCAL aFileList := {} && File list array
LOCAL nFiles && Number of font file in directory
LOCAL nChoice && Choice
LOCAL nCnt && Counter
LOCAL cFntFile && Name of chosen font file
LOCAL cOldCol && Screen color
LOCAL nRetCode && Return code R_FntFile
*-- Get the complete directory to aDirectory
aDirectory := Directory ( '*.*' )
*-- Number of files in the current directory
nFiles := Len ( aDirectory )
IF nFiles < 1
Alert ( 'No files found in current directory ...' )
RETURN nil
ENDIF
*-- Compose a file list
FOR nCnt := 1 TO nF